﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


/// <summary>
/// CategoryAndBrand 的摘要描述
/// </summary>
public class CategoryAndBrand
{
	public IEnumerable<Category> getCategory()
	{
        UboxContext db = new UboxContext();

        var cates = db.category.Select(c => new Category { CategoryID=c.category_id, CategoryName=c.category_name });

        return cates;
	}

    public IEnumerable<Brand> getBrand()
    {
        UboxContext db = new UboxContext();

        var brands = db.brand.Select(b => new Brand { BrandID = b.brand_id, BrandName = b.brand_name });

        return brands;
    }

    public IEnumerable<ProductS> getProduct(string BrandID, string CategoryID)
    {
        UboxContext db = new UboxContext();
        int bid = int.Parse(BrandID);
        int cid = int.Parse(CategoryID);
        var pros = db.production_product.Where(p => p.brand_id == bid && p.category_id == cid).Select(p => new ProductS { ProductID = p.product_id, ProductName = p.product_name });

        return pros;
    }

}